package com.tianqu.tms.core.util;

import java.util.ArrayList;
import java.util.Collections;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.entity.TmsSmsInfo;

public class MobileMessageUtils {
	protected static Logger LOGGER = Logger.getLogger(MobileMessageUtils.class);
	private static final String MESSAGE_SN = "SDK-DLS-010-00344";
	private static final String MESSAGE_PW = "911922";

	public static void sendMobileMessage(String message) {
		String phoneNumber = Registry.getConfig(TmsConstants.MOBILE_PHONE_KEY);
		if (!"on".equalsIgnoreCase(Registry.getConfig(TmsConstants.MOBILE_PHONE_SWITCH_KEY)))
			return;
		try {
			TmsSmsInfo sms = new TmsSmsInfo();
			sms.setSerial(String.valueOf(System.currentTimeMillis()));
			sms.setSmsContent(message);
			sms.setInsertUserId(TmsConstants.SYSTEM_OPERATOR_ID);
			sms.setOwnerPhone(phoneNumber);
			sms.setPepType(2);
			sms.setSendFrom(2);
			sms.insertSmsInfo(sms);
			//TODO::SEND MAIL
//			Client client = new Client(MESSAGE_SN, MESSAGE_PW);
//			ArrayList<String> numbers = new ArrayList<String>();
//			Collections.addAll(numbers, phoneNumber.split(","));
//			client.mt(numbers, message, "", "", "");
		} catch (Exception e) {
			LOGGER.error("send message error.", e);
		}
	}
}
